package test20230508;

/**
 * @author 兴趣使然黄小黄
 * @version 1.0
 * @date 2023/5/8 22:30
 */
public class Main01 {

    public static void main(String[] args) {
        // 创建一个 student 对象, 初始化信息并打印
        Citizen student = new Student("蒲小七", "女", "2001-05", "20408010120", "2022-09", 520);
        student.showInfo();
    }
}

/**
 * 公民类
 */
class Citizen {
    private String name; // 姓名
    private String gender; // 性别
    private String date; // 出生年月:2001-05

    // 构造方法
    public Citizen() {
    }
    public Citizen(String name, String gender, String date) {
        this.name = name;
        this.gender = gender;
        this.date = date;
    }

    // 打印信息
    public void showInfo() {
        System.out.println("姓名:\t" + this.name);
        System.out.println("性别:\t" + this.gender);
        System.out.println("出生年月:\t" + this.date);
    }
}

/**
 * 学生子类
 */
class Student extends Citizen {
    private String id; // 学号
    private String registrationDate; // 注册时间
    private int entranceTestScore; // 入学成绩

    // 构造方法
    public Student(String name, String gender, String date, String id, String registrationDate, int entranceTestScore) {
        super(name, gender, date);
        this.id = id;
        this.registrationDate = registrationDate;
        this.entranceTestScore = entranceTestScore;
    }

    // 重写打印信息的方法
    @Override
    public void showInfo() {
        super.showInfo(); // 先打印父类的基本信息
        // 打印其余信息
        System.out.println("学号:\t" + this.id);
        System.out.println("注册时间:\t" + this.registrationDate);
        System.out.println("入学成绩:\t" + this.entranceTestScore);
    }
}
